import React, { Component } from 'react'

export default class App extends Component {
    state = {
        text: '',
        list: ['11', '22', '33']
    }
    render() {
        return (
            <div>
                <h1>单元测试用例</h1>
                <input onChange={(evt) => {
                    this.setState({
                        text: evt.target.value
                    })
                }}></input>
                <button className='add' onClick={() => {
                    this.setState({
                        list: [...this.state.list, this.state.text]
                    })
                }}>add</button>
                <ul>
                    {
                        this.state.list.map((item, index) => {
                            return <li key={index}>{item} <button className='del' onClick={(index) => {
                                let newList = [...this.state.list]
                                newList.splice(index, 1)
                                this.setState({
                                    list: newList
                                })
                            }}>删除</button></li>
                        })
                    }
                </ul>
            </div>
        )
    }
}
